<template>
  <div class="mod-config">
    <basic-container>
      <navigationZDRW :sign="{ a: false, b: true, c: false }"></navigationZDRW>
      <div v-if="showZhong == 1" class="boxsty zhiBiao">
        <div :height="searchheight">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <el-form
              :inline="true"
              :model="dataForm"
              @keyup.enter.native="getDataList()"
              class="form-inline"
            >
              <el-form-item label="发起名称">
                <el-input
                  v-model="dataForm.faqiName"
                  placeholder="发起名称"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人姓名">
                <el-input
                  v-model="dataForm.ryName"
                  placeholder="被考核人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人岗位">
                <el-input
                  v-model="dataForm.userZw"
                  placeholder="被考核人岗位"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  class="marginLeft"
                  @click="getDataList()"
                  >检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div class="border-top-theme">
          <div class="mt10" style="overflow: hidden">
            <div style="float: right">
              <el-button type="primary" plain @click="passAll()"
                >提交</el-button
              >
            </div>
          </div>
        </div>
        <el-table
          style="width: 100%; margin-top: 10px"
          :data="dataList"
          ref="table"
          border
          v-loading="dataListLoading"
        >
          <el-table-column
            type="selection"
            width="55"
            header-align="center"
            align="center"
          ></el-table-column>
          <el-table-column
            type="index"
            width="80"
            header-align="center"
            align="center"
            label="序号"
          ></el-table-column>
          <el-table-column
            prop="faqiName"
            header-align="center"
            align="center"
            width="200"
            show-overflow-tooltip
            label="发起名称"
          >
          </el-table-column>
          <el-table-column
            prop="ryName"
            header-align="center"
            align="center"
            min-width="120"
            label="被考核人"
          >
          </el-table-column>
          <el-table-column
            prop="userZw"
            header-align="center"
            align="center"
            min-width="150"
            label="被考核人岗位"
          >
          </el-table-column>
          <el-table-column
            prop="zp"
            header-align="center"
            align="center"
            min-width="90"
            label="自评分"
          >
          </el-table-column>
          <el-table-column
            prop="pj"
            header-align="center"
            align="center"
            min-width="90"
            label="领导评分"
          >
          </el-table-column>
          <el-table-column
            prop="order"
            header-align="center"
            align="center"
            min-width="90"
            label="其他奖惩"
          >
          </el-table-column>
          <el-table-column
            prop="count"
            header-align="center"
            min-width="90"
            align="center"
            label="最终评分"
          >
            <template slot-scope="scope">
              {{ scope.row.count.toFixed(2) }}
            </template>
          </el-table-column>
          <el-table-column
            prop="xiu"
            header-align="center"
            min-width="100"
            align="center"
            label="修正系数"
          >
          </el-table-column>
          <el-table-column
            prop="nan"
            header-align="center"
            min-width="100"
            align="center"
            label="难度系数"
          >
          </el-table-column>
          <el-table-column
            prop="score"
            header-align="center"
            align="center"
            min-width="100"
            label="考核得分"
          >
          </el-table-column>
          <el-table-column
            header-align="center"
            align="center"
            fixed="right"
            min-width="90"
            label="操作"
          >
            <template slot-scope="scope">
              <el-button
                type="primary"
                plain
                size="small"
                @click="preview(scope.row)"
                >其他奖惩</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
      <zdfqForm
        v-if="showZhong == 2"
        ref="zdfqRef"
        :zdfqForm="zdfqForm"
        v-on:zdrwfqC="zdrwfqC"
      ></zdfqForm>
    </basic-container>
  </div>
</template>

<script>
import zdfqForm from "@/views/hetongrenwu/components/zhongdianfq-form.vue";
import { radioTwoList } from "@/api/hetongrenwu/hetonghtxxdjb";
import { validatenull } from "@/util/validate";
import {
  fetchListQt,
  getScorePj,
  passAll,
} from "@/api/hetongrenwu/zhongdian/renwutianbao";
export default {
  components: {
    zdfqForm,
  },
  data() {
    return {
      dataForm: {},
      radio: "1",
      radioTwo: "1",
      dataList: [],
      dataListLoading: false,
      showZhong: 1,
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      zdfqForm: {},
      searchadvanced: true,
      searchheight: "0",
      radioTwoList: radioTwoList,
    };
  },
  created() {
    let params = this.$route.query;
    if (!validatenull(params)) {
      this.radioTwo = params.radioTwo;
    }
    this.getDataList();
  },
  methods: {
    passAll() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.warning("请勾选所提交的数据");
      } else {
        this.$prompt("请对这" + data.length + "条指标填写审批意见", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          inputValue: "暂无意见",
        }).then(({ value }) => {
          passAll({ rows: data, message: value }).then((res) => {
            this.$message.success(res.data.data);
            this.getDataList();
          });
        });
      }
    },
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "auto";
      }
    },
    //预览
    preview(row) {
      getScorePj({
        id: row.id,
        showAll: 1,
      }).then((res) => {
        this.showZhong = 2;
        this.$nextTick(() => {
          this.zdfqForm = {
            enter: "2",
            disabled: true,
          };
          this.$refs.zdfqRef.init(res.data.data);
        });
      });
    },
    //子集
    zdrwfqC(zdrwfqC) {
      if (zdrwfqC) {
        this.showZhong = 1;
        this.getDataList();
      }
    },
    getDataList() {
      this.dataListLoading = true;
      fetchListQt(
        Object.assign(
          {
            current: this.pageIndex,
            size: this.pageSize,
          },
          this.dataForm
        )
      ).then((response) => {
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
        this.dataListLoading = false;
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
  },
};
</script>

<style>
</style>
